package com.shangze.test.ui.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.widget.Button;
import android.widget.TextView;

import com.shangze.test.R;
import com.shangze.test.base.BaseFragment;
import com.shangze.test.presenter.fragment.HomePresenter;
import com.shangze.test.presenter_view.EntityView;

import butterknife.BindView;
import butterknife.OnClick;


/**
 * A simple {@link Fragment} subclass.
 * Activities that contain this fragment must implement the
 * to handle interaction events.
 * Use the {@link HomeFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class HomeFragment extends BaseFragment<HomePresenter> implements EntityView {

    @BindView(R.id.text)
    TextView text;
    @BindView(R.id.btn)
    Button btn;


    // TODO: Rename and change types and number of parameters
    public static HomeFragment newInstance() {
        HomeFragment fragment = new HomeFragment();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public void initView() {
        text.setText("这里有数据馁");
//        presenter.attachView(entityView);
    }


    @Override
    protected int provideContentViewId() {
        return R.layout.fragment_home;
    }

    @Override
    public HomePresenter createPresenter() {
        return new HomePresenter(getActivity());
    }

    @OnClick(R.id.btn)
    public void onViewClicked() {
        presenter.getSearchBooks("金瓶梅", null, 0, 1);
    }

    @Override
    public void model(int pos, Object data) {

    }
/*
    @Override
    public void onSuccess(int state, Object data) {
        LogTool.i("1111：");
        Book book = (Book) data;
        LogTool.i("222222：");
        LogTool.i("什么鬼1111：" + data.toString());
        if (book != null) {
            text.setText(book.toString());
        }
    }

    @Override
    public void onError(int state, String result) {
        LogTool.i("什么鬼2222：" + result);
    }*/


}
